package cn.com.pc.content.controller;

import cn.com.pc.content.domain.Site;
import cn.com.pc.content.domain.abuse.AbuseReport;
import cn.com.pc.content.domain.abuse.AbuseReportRepository;
import cn.com.pc.content.dto.AbuseReportDTO;
import cn.com.pc.content.dto.PageForm;
import cn.com.pc.content.dto.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 举报管理
 */
@RestController
@RequestMapping("/abuse-reports")
public class AbuseReportController {

    private final AbuseReportRepository abuseReportRepository;

    public AbuseReportController(AbuseReportRepository abuseReportRepository) {
        this.abuseReportRepository = abuseReportRepository;
    }

    /**
     * 创建举报内容
     */
    @PostMapping
    public Long createAbuseReport(@RequestHeader("Site") Site site, AbuseReportDTO abuseReportDTO) {
        AbuseReport abuseReport = abuseReportDTO.to();
        abuseReport.setId(null);
        abuseReportRepository.save(abuseReport);
        return abuseReport.getId();
    }

    /**
     * 搜索举报内容
     */
    @GetMapping
    public PageResult<AbuseReportDTO> listAbuseReportByForm(@RequestHeader("Site") Site site, AbuseReportDTO abuseReportDTO, PageForm pageForm) {
        return null;
    }
}
